
from typing import List
from list_node import ListNode

class Solution:
    def printListFromTailToHead(self , listNode: ListNode) -> List[int]:
        res = []
        while listNode:
            res.insert(0, listNode.val)
            listNode = listNode.next
        return res
if __name__ == '__main__':
     tail = ListNode(3)
     mid = ListNode(2)
     head = ListNode(1)
     head.next = mid
     mid.next = tail
     print(Solution().printListFromTailToHead(head))
